package com.itheima.udp;

import java.io.IOException;
import java.net.*;
import java.util.Scanner;

//练习：
//发送端：数据来源于键盘录入，直到录入的数据是886，发送数据接收
//接受端：接受端不知道发送端什么时候停止数据，故采用死循环接受
public class SockdetDemoPrice01 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        DatagramSocket da = new DatagramSocket();
        while (true) {
            System.out.println("请输入");
            String num = sc.next();
            if("886".equals(num)){
                break;
            }
            byte[] bytes = num.getBytes();
            InetAddress in = InetAddress.getByName("10.254.7.211");
            int port = 8080;
            DatagramPacket dp = new DatagramPacket(bytes, bytes.length, in,port);
            da.send(dp);
        }
        da.close();
    }
}
